package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.BProjectCompany;
import com.ruoyi.system.domain.vo.BCompanyVo;
import com.ruoyi.system.service.BProjectCompanyService;
import com.ruoyi.system.mapper.BProjectCompanyMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author yangxingze
* @description 针对表【b_project_company(项目药企关联表)】的数据库操作Service实现
* @createDate 2025-01-03 01:33:34
*/
@Service
public class BProjectCompanyServiceImpl extends ServiceImpl<BProjectCompanyMapper, BProjectCompany>
    implements BProjectCompanyService{

    /**
     * 根据项目id删除关联的药企
     * @param projectId
     */
    @Override
    public void deleteProjectCompanyByProjectId(Long projectId) {
        baseMapper.deleteProjectCompanyByProjectId(projectId);
    }

    /**
     * 保存项目药企关联信息
     * @param companyList
     * @param projectId
     */
    @Override
    public void saveProjectCompany(List<BCompanyVo> companyList, Long projectId) {
        if(ObjectUtils.isNotEmpty(companyList)){
            for(BCompanyVo companyVo:companyList){
                BProjectCompany bProjectCompany = new BProjectCompany();
                bProjectCompany.setCompanyId(companyVo.getId());
                bProjectCompany.setProjectId(projectId);
                bProjectCompany.setCreateTime(new Date());
                this.save(bProjectCompany);
            }
        }
    }
}




